package com.coderlin.controller;

import com.coderlin.entities.Salary;
import com.coderlin.service.SalaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * <Description> <br>
 *
 * @author Coder_Lin<br>
 * @version 1.0<br>
 * @taskId: <br>
 * @createDate 2021/07/28 9:32 <br>
 * @see com.coderlin.controller <br>
 */
@Controller
@RequestMapping("/salary")
public class SalaryController {

    @Autowired
    private SalaryService salaryService;

    @RequestMapping("/listSalary")
    public String listSalary(Model model){
        List<Salary> salaries = salaryService.listSalary();
        model.addAttribute("salaryList",salaries);

        return "salaryList";
    }

    @RequestMapping("/calcSalary")
    public String calcSalary(String workerName, String timeStart, String timeEnd,Model model){
        List<Salary> salaries = salaryService.calcSalary(workerName,timeStart, timeEnd);
        model.addAttribute("salaryList",salaries);

        return "salaryList";
    }

}
